package benchmark

import (
	"encoding/json"
	"net/http"
)

type DaemonStats struct {
	CacheDir    string `json:"cache_dir"`
	CacheSize   int64  `json:"cache_size"`
	CacheHit    int    `json:"cache_hit"`
	CacheMiss   int    `json:"cache_miss"`
	Downloaded  int    `json:"blocks_downloaded"`
}

func FetchDaemonStats() (*DaemonStats, error) {
	resp, err := http.Get("http://127.0.0.1:8090/status")
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()

	var stats DaemonStats
	if err := json.NewDecoder(resp.Body).Decode(&stats); err != nil {
		return nil, err
	}
	return &stats, nil
}
